function x=gls(x0,sd,sl,conv,f0,f1,f2)
% General line search framework
% INPUT:
%       x0 - the initial point;
%       sd - string to specify the method to compute the search direction;
%       sl - string to specify the method/condition to compute the
%       steplength;
%       conv - convergence criteria;
% OUTPUT:
%       x - solution;
% REVISION:
%       jqin, 15/feb/2011, created;
switch sd
    case 'Newton'
        fsd=@(x)newtonm_d(x,f1,f2);
    case 'SteepestD'
        fsd=@(x)stdt(x,f1);
end
sl=@(x,p)backtk(sl,a0,x,p,c,f0,f1,rho);
% FIXME: for Newton's method, the steplength should be 1;
x=x0;
k=0;
while abs(f1(x))>conv
    p=fsd(x);
    a=sl(x,p);
    x=x+a*p;
    k=k+1;
end
        
